<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>4760：[Usaco2017 Jan]Hoof, Paper, Scissors</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2017 Jan]Hoof, Paper, Scissors</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2017 Jan]Hoof, Paper, Scissors</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Usaco2017 Jan]Hoof, Paper, Scissors                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>You have probably heard of the game &quot;Rock, Paper, Scissors&quot;. The cows like to play a similar game th</div>
<div>ey call &quot;Hoof, Paper, Scissors&quot;</div>
<div>你可能玩过石头剪刀布这个游戏，奶牛们也喜欢玩类似的游戏，叫做&ldquo;蹄子剪刀布&rdquo;</div>
<div>The rules of &quot;Hoof, Paper, Scissors&quot; are simple. Two cows play against each-other. They both count t</div>
<div>o three and then each simultaneously makes a gesture that represents either a hoof, a piece of paper</div>
<div>, or a pair of scissors. Hoof beats scissors (since a hoof can smash a pair of scissors), scissors b</div>
<div>eats paper (since scissors can cut paper), and paper beats hoof (since the hoof can get a papercut).</div>
<div>&nbsp;For example, if the first cow makes a &quot;hoof&quot; gesture and the second a &quot;paper&quot; gesture, then the sec</div>
<div>ond cow wins. Of course, it is also possible to tie, if both cows make the same gesture.</div>
<div></div>
<div>蹄子剪刀布的规则和石头剪刀布的规则是一样的，蹄子踩碎剪刀，剪刀剪布，布包蹄子</div>
<div></div>
<div>Farmer John wants to play against his prize cow, Bessie, at N games of &quot;Hoof, Paper, Scissors&quot; (1&le;N</div>
<div>&le;100,000). Bessie, being an expert at the game, can predict each of FJ's gestures before he makes i</div>
<div>t. Unfortunately, Bessie, being a cow, is also very lazy. As a result, she tends to play the same ge</div>
<div>sture multiple times in a row. In fact, she is only willing to switch gestures at most KK times over</div>
<div>&nbsp;the entire set of games (0&le;K&le;20). For example, if K=2, she might play &quot;hoof&quot; for the first few ga</div>
<div>mes, then switch to &quot;paper&quot; for a while, then finish the remaining games playing &quot;hoof&quot;.</div>
<div></div>
<div>现在FJ想要和他的最机智的奶牛Bessie玩蹄子剪刀布（我也不知道FJ为什么有蹄子），一共进行了N轮(N&lt;=1e5)，B</div>
<div>essie，作为一个奶牛，非常的怠惰，无论她出什么，都喜欢连续的出，最多变化K次(K&lt;=20)，也就是说，对于她</div>
<div>所出的，记为序列f(i)，记sum=有多少个i满足f(i)!=f(i-1)(i&gt;1)，而她的sum一定不会超过k</div>
<div>Given the sequence of gestures FJ will be playing, please determine the maximum number of games that</div>
<div>&nbsp;Bessiecan win.</div>
<div></div>
<div>现在FJ已经给出了他出的东西，你要告诉Bessie，在不确定她出的东西的情况下，她最多能赢多少次</div>
<div></div>
<p></p></p><hr/><h3>输入格式</h3><p><div>The first line of the input file contains N and K.</div>
<div>输入数据第一行为N,K</div>
<div>The remaining N lines contains FJ's gestures, each either H, P, or S</div>
<div>接下来N行表示FJ所出的东西，H表示hoof,P表示paper,S表示Scissors</div>
<div></div>
<p></p></p><hr/><h3>输出格式</h3><p><div></div>
<div>
<div>Print the maximum number of games Bessie can win, given that she can only change gestures at most KK times.</div>
<div>输出在变化不超过K次的前提下，最多能赢多少次</div>
</div>
<div></div>
<p></p></p><hr/><h3>样例输入</h3><pre>5 1
P
P
H
P
S</pre><hr/><h3>样例输出</h3><pre>4</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>Gold</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=4760" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=4760" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>